package com.ruoyi.shop.emporium.profit.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.mall.common.domain.ProfitLossStatement;
import com.ruoyi.shop.emporium.profit.service.IProfitLossStatementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/emporium/profit")
public class ProfitLossStatementController extends BaseController {

    @Autowired
    private IProfitLossStatementService profitLossStatementService;

    @PreAuthorize("@ss.hasPermi('emporium:profit:list')")
    @GetMapping("/list")
    public TableDataInfo getProfitLossStatement(
            @RequestParam Date beginDate,
            @RequestParam Date endDate,
            @RequestParam(defaultValue = "daily") String type) {

        startPage();
        List<ProfitLossStatement> list = profitLossStatementService.getProfitLossStatement(beginDate, endDate, type);
        return getDataTable(list);
    }
}
